unit Form_Server;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, rtcInfo, rtcConn, rtcDataSrv, rtcHttpSrv;

type
  TForm1 = class(TForm)
    HttpServer1: TRtcHttpServer;
    DataProvider1: TRtcDataProvider;
    procedure FormActivate(Sender: TObject);
    procedure DataProvider1CheckRequest(Sender: TRtcConnection);
    procedure DataProvider1DataReceived(Sender: TRtcConnection);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzDebug;

{$R *.dfm}

procedure TForm1.DataProvider1CheckRequest(Sender: TRtcConnection);
var
  DataServer:TRtcDataServer absolute Sender;
begin
  with DataServer do
  begin
    if Request.Method='POST' then
    begin
      if UpperCase(Request.FileName) ='/FORMPARAM' then
      begin
        Accept;
      end;
    end;
  end;
end;

procedure TForm1.DataProvider1DataReceived(Sender: TRtcConnection);
var
  DataServer:TRtcDataServer absolute Sender;
begin
  with DataServer do
  begin
    if Request.Complete then
    begin
      Request.Params.AddText(Read);
      KzDebug.FileFmt('%S',[Request.Params.Value['params-username']]);
      KzDebug.FileFmt('%S',[Request.Params.Value['params-password']]);
      KzDebug.FileFmt('%S',[Request.Query.Value['query-username']]);
      KzDebug.FileFmt('%S',[Request.Query.Value['query-password']]);
      KzDebug.FileFmt('read:%S',[read]);

      Write('ok');
    end;
  end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  HttpServer1.ServerPort:='8080';
  HttpServer1.Listen();
end;

end.
